//q4.cpp
//The program takes a real number and round it according to the user input
//
//Binyamin 22 december 2017
//-----------------------------------------------------------
#include <iostream>

using namespace std;

const int ROUND_DOWN = 1;
const int ROUND_UP = 2;
const int ROUND = 3;

// 1. prompt the user for method.
// 2. capture the method.
// 3. prompt the user for a number.
// 4. capture the number.
// 5. round according to method.

int main()
{
	int choice; // choice - the user operation choice.
	double num; // num - the number from the user to round.
	int rounded; // rounded - the rounded number.

	cout << "Choose your round method:" << endl \
		<< "1. Floor round" << endl \
		<< "2. Ceiling round" << endl \
		<< "3. Round to the nearest whole number" << endl;
	cin >> choice;
	cout << "Please enter your number" << endl;
	cin >> num;

	if(choice == ROUND_DOWN)
	{
		rounded = (int)num;
	}
	if(choice == ROUND_UP)
	{
		rounded = (int)num + 1;
	}
	if(choice == ROUND)
	{
		rounded = (int)(num + 0.5);
	}

	cout << "The rounded value of " << num << " is " << rounded << endl;

	return 0;
}
//output
//Choose your round method:
//1. Floor round
//2. Ceiling round
//3. Round to the nearest whole number
//3
//Please enter your number
//2.4
//The rounded value of 2.4 is 2
